Những câu hỏi liên quan
Nguyễn Thị Linh
Xem chi tiết
Minh Lệ
6 tháng 1 2022 lúc 21:03

Program HOC24;

var i,n: byte;

A: array[1..100] of integer;

t: longint;

begin

write('Nhap N: '); readln(N);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do if a[i] mod 2=0 then t:=t+a[i];

write('Tong cac so chan la: ',t);

readln

end.

Bình luận (0)
Thiên Nhật
Xem chi tiết
Vương Hương Giang
14 tháng 2 2022 lúc 14:26

uses crt;

var a:array[1..100]of integer;

i,n,tc,tl,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

tc:=0;

tl:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then tc:=tc+a[i]

else tl:=tl+a[i];

end;

writeln('Tong cac so chan la: ',tc);

writeln('Tong cac so le la: ',tl);

t:=0;

for i:=1 to n do  

t:=t+a[i];

writeln('Tong cua day so la: ',t);

readln;

end. 

Bình luận (0)
Nguyễn Lê Phước Thịnh
14 tháng 2 2022 lúc 14:32

uses crt;

var a:array[1..1000]of integer;

i,n,dem1,dem2,t1,dem3,j,kt:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

dem1:=0;

dem2:=0;

t1:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem1:=dem1+1;

t1:=t1+a[i];

end;

else dem2:=dem2+1;

end;

dem3:=0;

for i:=1 to n do 

  if (a[i]>1) then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then dem3:=dem3+1;

end;

writeln(dem1, ' ',dem2);

writeln(t1);

writeln(dem3);

readln;

end.

Bình luận (0)
Thái Bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 20:08

uses crt;

var a:array[1..100]of integer;

i,n,tc,tl,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

tc:=0;

tl:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then tc:=tc+a[i]

else tl:=tl+a[i];

end;

writeln('Tong cac so chan la: ',tc);

writeln('Tong cac so le la: ',tl);

t:=0;

for i:=1 to n do  

t:=t+a[i];

writeln('Tong cua day so la: ',t);

readln;

end. 

Bình luận (1)
Nguyễn Mai
Xem chi tiết
Ngô Bá Hùng
16 tháng 4 2023 lúc 10:09

program BaiToanMang;

var
  A: array[1..100] of integer;
  N, i, demChan, tongLeChia3: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(N);
  writeln('Nhap cac phan tu cua mang: ');
  for i := 1 to N do
  begin
    write('a[', i, ']= ');
    readln(A[i]);
  end;
  tongLeChia3 := 0;
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
    begin
      tongLeChia3 := tongLeChia3 + A[i];
    end;
  end;
  writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
  demChan := 0;
  for i := 2 to N do
  begin
    if (A[i] mod 2 = 0) and (i mod 2 = 1) then
    begin
      demChan := demChan + 1;
    end;
  end;
  writeln('So phan tu chan o vi tri le: ', demChan);
  writeln('Cac so chan chia het cho 5: ');
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
    begin
      write(A[i], ' ');
    end;
  end;
end.

ko bt đúng ko ko dùng pascal nhiều

Bình luận (1)
Ngô Bá Hùng
16 tháng 4 2023 lúc 10:02

b dùng pascal hay python V:

Bình luận (3)
Du Ng
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 12 2021 lúc 22:47

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,dem;

int main()

{

cin>>n;

dem=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x>0) dem++;

}

cout<<dem;

return 0;

}

Bình luận (1)
Du Ng
Xem chi tiết
Thanh Nhi Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:12

Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé

uses crt;

var a:array[1..100]of integer;

i,n,t,t1,t2:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

 begin

write('A[',i,']='); readln(a[i]);

edn;

t:=0;

for i:=1 to n do 

 t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
Như Quỳnh
Xem chi tiết
Kiều Vũ Linh
11 tháng 5 2022 lúc 11:08

Em ghi lại cho đúng cái đề nhé

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 5 2022 lúc 13:13

uses crt;

var a:array[1..10000]of integer;

i,n,kt,j:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then write(a[i]:4);

end;

readln;

end.

Bình luận (0)
Như Quỳnh
Xem chi tiết
Như Quỳnh
11 tháng 5 2022 lúc 7:26

mn gips em ạ

 

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 5 2022 lúc 13:13

uses crt;

var a:array[1..10000]of integer;

i,n,kt,j:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then write(a[i]:4);

end;

readln;

end.

Bình luận (0)